package com.example;

import java.util.Scanner;

public class MaxSubSumOfSequence {
    public String maxArray(String aa) {
//        Scanner scanner = new Scanner(System.in);
        int sum = 0;
        int max;
        String regex = "([0-9]+[,]{1})*[0-9]*";
//        String s = scanner.next().toString();
        String s=aa;
//        while (!s.matches(regex)) {
//            System.out.println("输入不规范请重新输入,数字键用‘,’分隔");
//            s = scanner.next().toString();
//        }
        if(!s.matches(regex)){
            System.out.println("输入不规范请重新输入,数字键用‘,’分隔");
        }
        String[] ss = s.split(",");
        int[] a = new int[ss.length];
        for (int i = 0; i < ss.length; i++) {
            a[i] = Integer.parseInt(ss[i]);
        }
        max = a[0];
        for (int i = 0; i < a.length; i++) {
            if (sum > 0)
                sum += a[i];
            else
                sum = a[i];
            max = Math.max(max, sum);
        }

        return max+"";
    }
}
